<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

class Category extends Model
{
    public $table = 'category';
    public $primaryKey = 'cate_id';
    public $timestamps = true;

    public function gettree()
    {
        $cate = $this->select(['cate_id','cate_pid','cate_name','cate_title','cate_order'])->orderBy('cate_order', 'asc')->get();
        $arr = [];
        foreach ($cate as $v) {
            if ($v->cate_pid == 0) {
                $arr[] = $v;
            }
        }
        return $cate;
        //{"id":1,"pid":0,"title":"1-1"}
    }
}
